# coding=UTF-8
'''
Created on 2018年4月28日

采集主页面方法
@author: lijie
'''
from businessLayer.page_element.common_element.delete_pop_page import DeletePopPage
from businessLayer.page_element.metadata.metadata_collection_page import MetaCollectionPage
from businessLayer.utilites.gvcommon import Common

class MetaCollectionPageFun():
        
    def delete_collection(self,title):
        MetaCollectionPage().LblCreateDTByTitle(title).mouse_hover()
        Common().wait_sleep(2)
        MetaCollectionPage().BtnDeleteByTitle(title).click()
        DeletePopPage().BtnDeleteConfirm().wait_present_and_click()
        Common().wait_sleep(1)
        MetaCollectionPage().LblCollTitleByName(title).should_unexist()
        
    def get_colletcion_amount(self):
        '''取得采集list中所有采集元素   
        return: list element   
        '''
        els=MetaCollectionPage().LblCollTitleByName('').elements()
        return els
    
    def search_by_status(self,sta):
        MetaCollectionPage().BtnSearchByStatus(sta).click()
        Common().wait_sleep(1)
        return self.get_colletcion_amount()
    
    def search_by_name(self,name):
        MetaCollectionPage().TxtNameSearch().input(name)
        MetaCollectionPage().BtnNameSearch().click()
        return self.get_colletcion_amount()
        
        